<template>
<div class="submit_team_box">
  <a-table class="main_table" :style="{ minHeight: '670px' }"
           :columns="columns"
           :data="submitTeamList"
           size="large"
           style="min-height: 530px"
           @row-click="showSubmitTeamDetail">
    <template #solutionStatus="{record}">
      <icon-sun-fill />
      <a-link >
        {{ !record.status ? '待判题' : record.status === 1 ? '判题中' : record.status == 2 ? '成功' : '失败'}}
      </a-link>
    </template>
    <template #language="{record}">
      <a-tag>
        {{ record.language }}
      </a-tag>
    </template>
    <template #timeLimit="{record}">
      {{ record.judgeinfo?.timeLimit }} ms
    </template>
    <template #memoryLimit="{record}">
      {{ record.judgeinfo?.memoryLimit }}
    </template>
  </a-table>
</div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { QuestionSubmitControllerService } from "../../generated";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
import { Message } from "@arco-design/web-vue";

const columns = [
  {
    title: '所有状态',
    slotName: 'solutionStatus'
  }, {
    title: '所有语言',
    slotName: 'language',
  }, {
    title: '执行时间',
    slotName: 'timeLimit',
  }, {
    title: '内存消耗',
    slotName: 'memoryLimit'
  },
];
const route = useRoute();
const router = useRouter();
const store = useStore();
const submitTeamList = ref([])
let qid = 0;
let uid = 0;
onMounted(async () => {
  qid = route.query?.id;
  uid = store.state.user?.curUser?.id;
  // 根据qid和uid获取提交数据
  let res = await QuestionSubmitControllerService.getQuestionSubmitByUIdQIdUsingGet(qid, uid);
  console.log('61 test', res);
  if (res.code == 0) {
    submitTeamList.value = res.data;
    console.log('submitTeamList', submitTeamList.value);
  }else {
    Message.error(res.msg);
  }
})

const showSubmitTeamDetail = (teamItem) => {
  console.log('showSubmitTeamDetail', teamItem.id);
  router.push({path: `/submitTeamDetail`, query:{id:teamItem.id}})
}
</script>

<style scoped>
.submit_team_box{

}
</style>